package com.daocao.auth.controller;


import com.daocao.common.entity.UmsSysUser;
import com.daocao.common.service.UmsSysUserService;
import com.daocao.common.response.DaoCaoResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("ums/sysuser")
public class UmsSysUserController {

    private final UmsSysUserService sysUserService;

    public UmsSysUserController(UmsSysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }


    @PostMapping
    public DaoCaoResult addSysUser(@RequestBody UmsSysUser user) {
        boolean i = sysUserService.save(user);
        if (i) {
            return DaoCaoResult.success("用户创建成功");
        }
        return DaoCaoResult.error("用户创建失败");
    }

    @GetMapping
    public DaoCaoResult searchList() {
        List<UmsSysUser> list = sysUserService.list();
        list.forEach(System.out::println);
        return DaoCaoResult.success().put("data", list);
    }
}
